﻿
USE DBARC


------------------------------------------------------------------------------------------
/*
	sp_ADD_CATEGORY : Thêm 1 chủng loại thiết kế
*/
GO

if exists (select * from sysobjects where id = object_id('dbo.sp_ADD_CATEGORY') 
and sysstat & 0xf = 4)  drop procedure dbo.sp_ADD_CATEGORY

GO

CREATE PROCEDURE sp_ADD_CATEGORY
(
	@CODE INT,
	@NAME NVARCHAR(200),		
	@DESCRIPTION NVARCHAR(400),	
	@RECORD_STATUS BIT
)

AS

INSERT INTO CATEGORY 
VALUES(@CODE, @NAME, @DESCRIPTION, @RECORD_STATUS)

------------------------------------------------------------------------------------------
/*
	sp_UPDATE_CATEGORY : Cập nhật 1 chủng loại thiết kế
*/
GO
if exists (select * from sysobjects where id = object_id('dbo.sp_UPDATE_CATEGORY') 
and sysstat & 0xf = 4)  drop procedure dbo.sp_UPDATE_CATEGORY

GO

CREATE PROCEDURE sp_UPDATE_CATEGORY
(
	@ID INT,
	@CODE INT,
	@NAME NVARCHAR(200),		
	@DESCRIPTION NVARCHAR(400),	
	@RECORD_STATUS BIT
)

AS

UPDATE CATEGORY
SET  CODE = @CODE
	,NAME = @NAME
	,DESCRIPTION = @DESCRIPTION
	,RECORD_STATUS = @RECORD_STATUS
WHERE ID = @ID


------------------------------------------------------------------------------------------
/*
	sp_ADD_DESIGN : Thêm 1 thiết kế
*/
GO

if exists (select * from sysobjects where id = object_id('dbo.sp_ADD_DESIGN') 
and sysstat & 0xf = 4)  drop procedure dbo.sp_ADD_DESIGN

GO

CREATE PROCEDURE sp_ADD_DESIGN
(	
	@NAME NVARCHAR(300),
	@CAT_CODE INT,
	@INVESTOR NVARCHAR(100),
	@PRICE NVARCHAR(20),
	@IMAGE NVARCHAR(500),
	@INFORMATION NTEXT,
	@DESCRIPTION NTEXT,	
	@RECORD_STATUS BIT
)

AS

INSERT INTO DESIGN 
VALUES(@NAME, @CAT_CODE, @INVESTOR, @PRICE, @IMAGE, @INFORMATION, @DESCRIPTION, @RECORD_STATUS)
 

------------------------------------------------------------------------------------------
/*
	sp_UPDATE_DESIGN : Cập nhật 1 thiết kế
*/
GO

if exists (select * from sysobjects where id = object_id('dbo.sp_UPDATE_DESIGN') 
and sysstat & 0xf = 4)  drop procedure dbo.sp_UPDATE_DESIGN

GO

CREATE PROCEDURE sp_UPDATE_DESIGN
(	
	@ID INT,
	@NAME NVARCHAR(300),
	@CAT_CODE INT,
	@INVESTOR NVARCHAR(100),
	@PRICE NVARCHAR(20),
	@IMAGE NVARCHAR(500),
	@INFORMATION NTEXT,
	@DESCRIPTION NTEXT,	
	@RECORD_STATUS BIT
)

AS

UPDATE DESIGN
SET	 NAME = @NAME
	,CAT_CODE = @CAT_CODE
	,INVESTOR = @INVESTOR
	,PRICE = @PRICE
	,IMAGE = @IMAGE
	,INFORMATION = @INFORMATION
	,DESCRIPTION = @DESCRIPTION
	,RECORD_STATUS = @RECORD_STATUS
WHERE ID = @ID


------------------------------------------------------------------------------------------
/*
	sp_ADD_NEWS : Thêm 1 tin tức
*/
GO

if exists (select * from sysobjects where id = object_id('dbo.sp_ADD_NEWS') 
and sysstat & 0xf = 4)  drop procedure dbo.sp_ADD_NEWS

GO

CREATE PROCEDURE sp_ADD_NEWS
(	
	@TITLE NVARCHAR(400),	
	@SUMMARY NTEXT,		
	@IMAGE NVARCHAR(500),
	@DESCRIPTION NTEXT,	
	@RECORD_STATUS BIT
)

AS

INSERT INTO NEWS 
VALUES(@TITLE, @SUMMARY, @IMAGE, @DESCRIPTION, @RECORD_STATUS)


------------------------------------------------------------------------------------------
/*
	sp_UPDATE_NEWS : Cập nhật 1 tin tức
*/
GO

if exists (select * from sysobjects where id = object_id('dbo.sp_UPDATE_NEWS') 
and sysstat & 0xf = 4)  drop procedure dbo.sp_UPDATE_NEWS

GO

CREATE PROCEDURE sp_UPDATE_NEWS
(	
	@ID INT,
	@TITLE NVARCHAR(400),	
	@SUMMARY NTEXT,		
	@IMAGE NVARCHAR(500),
	@DESCRIPTION NTEXT,	
	@RECORD_STATUS BIT
)

AS

UPDATE NEWS
SET	 TITLE = @TITLE
	,SUMMARY = @SUMMARY
	,IMAGE = @IMAGE	
	,DESCRIPTION = @DESCRIPTION
	,RECORD_STATUS = @RECORD_STATUS
WHERE ID = @ID


------------------------------------------------------------------------------------------
/*
	sp_ADD_ADMINISTRATOR : Thêm 1 người quản trị
*/
GO

if exists (select * from sysobjects where id = object_id('dbo.sp_ADD_ADMINISTRATOR') 
and sysstat & 0xf = 4)  drop procedure dbo.sp_ADD_ADMINISTRATOR

GO

CREATE PROCEDURE sp_ADD_ADMINISTRATOR
(	
	@USERNAME NVARCHAR(50),		
	@PASSWORD NVARCHAR(50),	
	@RECORD_STATUS BIT
)

AS

INSERT INTO ADMINISTRATOR 
VALUES(@USERNAME, @PASSWORD, @RECORD_STATUS)


------------------------------------------------------------------------------------------
/*
	sp_ADD_FAQ : Thêm 1 câu hỏi
*/
GO

if exists (select * from sysobjects where id = object_id('dbo.sp_ADD_FAQ') 
and sysstat & 0xf = 4)  drop procedure dbo.sp_ADD_FAQ

GO

CREATE PROCEDURE sp_ADD_FAQ
(	
	@QUESTION NTEXT,	
	@ANSWER NTEXT,			
	@RECORD_STATUS BIT
)

AS

INSERT INTO FAQ 
VALUES(@QUESTION, @ANSWER, @RECORD_STATUS)

------------------------------------------------------------------------------------------
/*
	sp_UPDATE_FAQ : Cập nhật 1 câu hỏi
*/
GO

if exists (select * from sysobjects where id = object_id('dbo.sp_UPDATE_FAQ') 
and sysstat & 0xf = 4)  drop procedure dbo.sp_UPDATE_FAQ

GO

CREATE PROCEDURE sp_UPDATE_FAQ
(	
	@ID INT,
	@QUESTION NTEXT,	
	@ANSWER NTEXT,			
	@RECORD_STATUS BIT
)

AS

UPDATE FAQ
SET	 QUESTION = @QUESTION
	,ANSWER = @ANSWER	
	,RECORD_STATUS = @RECORD_STATUS
WHERE ID = @ID

------------------------------------------------------------------------------------------
/*
	sp_CHANGE_PASSWORD : Đổi Password người dùng
*/
GO

if exists (select * from sysobjects where id = object_id('dbo.sp_CHANGE_PASSWORD') 
and sysstat & 0xf = 4)  drop procedure dbo.sp_CHANGE_PASSWORD

GO

CREATE PROCEDURE sp_CHANGE_PASSWORD
(		
	@USERNAME NVARCHAR(50),	
	@PASSWORD NVARCHAR(50)	
)

AS

UPDATE ADMINISTRATOR
SET	 PASSWORD = @PASSWORD		
WHERE USERNAME = @USERNAME